package com.yuyou.train.user.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yuyou.train.service.api.user.entity.UserThoughts;
import com.yuyou.train.user.mapper.UserThoughtsMapper;
import com.yuyou.train.user.service.IUserThoughtsService;
import com.yuyou.train.util.bean.Pagination;
import com.yuyou.train.util.bean.ResBoolSimpleInfo;
import com.yuyou.train.util.tool.Sequence;
import com.yuyou.train.util.tool.UUIDUtil;

@Service
public class UserThoughtsServiceImpl implements IUserThoughtsService{

	@Autowired
	private UserThoughtsMapper userThoughtsMapper;
	
	@Override
	public int deleteByPrimaryKey(String id) {
		return userThoughtsMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int insert(UserThoughts record) {
		record.setId(Sequence.getSequence().getNextId());
		record.setCreateTime(new Date());
		return userThoughtsMapper.insert(record);
	}

	@Override
	public UserThoughts selectByPrimaryKey(String id) {
		return userThoughtsMapper.selectByPrimaryKey(id);
	}

	@Override
	public int updateByPrimaryKeySelective(UserThoughts record) {
		record.setUpdateTime(new Date());
		return userThoughtsMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public List<UserThoughts> findUserThoughtsByUserId(String userId) {
		return userThoughtsMapper.findUserThoughtsByUserId(userId);
	}

	@Override
	public List<UserThoughts> findUserThoughtsPageList(
			Pagination<UserThoughts> p) {
		return userThoughtsMapper.findUserThoughtsPageList(p);
	}

	@Override
	public int findUserThoughtsPageCount(Pagination<UserThoughts> p) {
		return userThoughtsMapper.findUserThoughtsPageCount(p);
	}

	@Override
	public ResBoolSimpleInfo<String> addUserThoughts(UserThoughts userThoughts) {
		this.insert(userThoughts);
		return ResBoolSimpleInfo.getSuccessInfo();
	}

	@Override
	public UserThoughts selectUserThoughts(String userId, String lessonId) {
		return userThoughtsMapper.selectUserThoughts(userId, lessonId);
	}




}